$(function () {
    var url = "/except/usercontroller/getuserinfo.action";
    var token = $("#token").val();
    if(isempty(token))
        token="null";
    var jsonstr = "{token:" + token + "}";
    $.ajax({
        url: url,
        type: 'post',
        dataType: "json",
        data: {
            json:jsonstr
        },
        async: false,
        success: function (data) {
            var code = data.code;
            var message = data.message
            if (code == 20000) {
                $("#headimg").attr("src", data.data.headimg);
                $("#username").html(data.data.nickname);
                var type = data.data.type;
                if(type == "0") {
                    // $("#usertype").attr("src", "img/vip_gray.png");
                    $("#storage").hide();
                    $("#storage_hr").hide();
                    $("#notproxy").show();
                    $("#proxy").hide();
                } else {
                    // $("#usertype").attr("src", "img/vip.png");
                    $("#notproxy").hide();
                    $("#proxy").show();
                    if(type == "1") {
                        $("#proxytype").html("普通代理");
                        $("#proxyimg").attr("src", "img/v1.png")
                    } else if(type == "2") {
                        $("#proxytype").html("银牌代理");
                        $("#proxyimg").attr("src", "img/v2.png")
                    } else if(type == "3") {
                        $("#proxytype").html("金牌代理");
                        $("#proxyimg").attr("src", "img/v3.png")
                    } else if(type == "4") {
                        $("#proxytype").html("砖石代理");
                        $("#proxyimg").attr("src", "img/v4.png")
                    } else if(type == "5") {
                        $("#proxytype").html("至尊代理");
                        $("#proxyimg").attr("src", "img/v5.png")
                    }
                }

                var logistic = data.data.logistic;
                if(isempty(logistic))
                    $("#logistic").hide();
                else {
                    $("#logistic").attr("onclick", "location.href='/except/files/indent/logistic.jsp?indentnum="+data.data.logistic.indentnum+"'");
                    $("#newtime").html(data.data.logistic.time);
                    $("#shopimg").attr("src", data.data.logistic.img);
                    $("#statedesc").html(data.data.logistic.statedesc);
                    $("#acceptStation").html(data.data.logistic.AcceptStation);
                    var state = data.data.logistic.State;
                    if(state == 2) {
                        $("#stateimg").attr("src", "img/passage.png");
                    } else
                        $("#stateimg").attr("src", "img/sign.png");
                }

                remove_advertising();
            } else if(code == 10001 || code == 10002){
                location.href = "/except/login.jsp";
            } else {
                $("#hintbg").show()
                $("#hint_message").html(message);
            }
        },

        // error: function(XMLHttpRequest, textStatus, errorThrown) {
        //     alert(XMLHttpRequest.status);
        //     alert(XMLHttpRequest.readyState);
        //     alert(textStatus);
        //     alert(errorThrown);
        // },
        //
        error: function (data) {
            $("#hintbg").show();
            $("#hint_message").html("网络错误");
        }
    });
});